﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace SpriteBuilder
{
    public class EditorTextureElement
    {
        public EditorTextureElement(Texture2D tex, Vector2 Position)
        {
            _texture = tex;
            _position = Position;
            _dstRectangle = new Rectangle((int)_position.X, (int)_position.Y, tex.Width, tex.Height);
            _marked = false;
        }

        private Texture2D _texture;
        public Texture2D texture
        {
            get { return _texture; }
            set { _texture = value; }
        }

        private Vector2 _position;
        private Rectangle _dstRectangle;
        /// <summary>
        /// Zielrechteck in das gezeichnet wird
        /// </summary>
        public Rectangle dstRectangle
        {
            get { return _dstRectangle; }
            set { _dstRectangle = value;
            _position = new Vector2(value.X, value.Y);
            }
        }

        private bool _marked;
        public bool marked { get { return _marked; } set { _marked = value; } }

        public Vector2 Position
        {
            get { return _position; }
            set
            {
                _position = value;
                _dstRectangle.Location = new Point((int)_position.X, (int)_position.Y);
            }
        }

        public bool beginDrag = false;

        public void Draw(SpriteBatch spriteBatch)
        {
            if (_marked)
            {
                // TODO Rahmen drumherum zeichnen
                spriteBatch.Draw(_texture, _dstRectangle, Color.Red);
            }
            else
            {
                spriteBatch.Draw(_texture, _dstRectangle, Color.White);
            }
        }
    }
}
